﻿Imports Zytonic_Hotkeys.ItemLibrary
Public Class frmDetail
    Public Methods As New Hashtable
    Public SelectedMethod As String
    Event KeyBind_Changed(ByVal Bind As DB_Item)
    Event KeyBind_Deleted(ByVal Bind As DB_Item)
    Event KeyBind_HandleChanged(ByVal ID As Integer, ByVal State As Boolean)
    Private Sub frmDetail_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Panel1.Size = New Drawing.Point(Panel1.Size.Width + 1, Panel1.Size.Height + 1)
        Panel1.Size = New Drawing.Point(Panel1.Size.Width - 1, Panel1.Size.Height - 1)
        InitBinds()
    End Sub
    Private Sub RefreshLabel()
        If KeyControl1.Text = Nothing Then
            Label1.Text = "Key 'Start Button' Mapping Details"
        Else
            Label1.Text = "Key '" & KeyControl1.Text & "' Mapping Details"
        End If
        Label2.Text = "Key State: " & KeyControl1.KeyState.ToString & vbNewLine & _
            "Key Display Type: " & KeyControl1.DisplayType.ToString & vbNewLine & _
            "Toggle State: " & KeyControl1.Toggled.ToString & vbNewLine & _
            "Control State: " & KeyControl1.State.ToString & vbNewLine & _
            "Symbol Size Mode:" & KeyControl1.SymbolSizeMode.ToString & vbNewLine & _
            "Symbol Padding: " & KeyControl1.SymbolPadding
        If KeyControl1.Image IsNot Nothing Then Label2.Text = Label2.Text & vbNewLine & "Dimensions: " & KeyControl1.Image.Size.Width & ", " & KeyControl1.Image.Size.Height & vbNewLine & "Pixel Format: " & KeyControl1.Image.PixelFormat.ToString
    End Sub
    Private Sub InitBinds()
        ComboBox1.Items.Clear()
        For Each Method As String In Methods.Keys
            ComboBox1.Items.Add(Method.Replace("_", " "))
        Next
        CheckBox1.Checked = KeyControl1.DisableHandle
        If SelectedMethod IsNot Nothing Then ComboBox1.Text = SelectedMethod.Replace("_", " ")
    End Sub
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        RefreshLabel()
    End Sub
    Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
        If ComboBox1.Text <> Nothing Then RaiseEvent KeyBind_Changed(New DB_Item(KeyControl1.Tag, New List(Of String) From {ComboBox1.SelectedItem.ToString.Replace(" ", "_")}))
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Try
            RaiseEvent KeyBind_Deleted(New DB_Item(KeyControl1.Tag, New List(Of String) From {ComboBox1.SelectedItem.ToString.Replace(" ", "_")}))
            ComboBox1.Text = Nothing
        Catch ex As Exception
        End Try
    End Sub
    Private Sub CheckBox1_Click(sender As Object, e As EventArgs) Handles CheckBox1.Click
        RaiseEvent KeyBind_HandleChanged(KeyControl1.Tag, CheckBox1.Checked)
    End Sub
End Class